package com.example;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

/**
 * 主页面
 */
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
    private EditText username;
    private EditText password;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        Button bt = findViewById(R.id.bt_bt1);
        bt.setOnClickListener(this);
        username=findViewById(R.id.et_username);
        password=findViewById(R.id.et_password);
    }

    @Override
    public void onClick(View view) {
        String name = username.getText().toString();
        String pass = password.getText().toString();
        if(name.equals("xiaohong")&&pass.equals("123456")){
            Toast.makeText(this,"恭喜您，登陆成功",Toast.LENGTH_SHORT).show();
            Intent intent =new Intent(this,SecondActivity.class);
            startActivity(intent);
        }else{
            Toast.makeText(this,"用户名或密码输入错误，请重新输入",Toast.LENGTH_SHORT).show();
        }
    }
}
